package com.java110.mall.cart.bmo.businessQuery.impl;

import com.alibaba.fastjson.JSONObject;
import com.java110.dto.product.ProductDto;
import com.java110.intf.goods.IProductInnerServiceSMO;
import com.java110.mall.cart.bmo.businessQuery.IBusinessQueryGoods;
import com.java110.utils.util.ListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessQueryGoodsImpl implements IBusinessQueryGoods {

    @Autowired
    private IProductInnerServiceSMO productInnerServiceSMOImpl;
    @Override
    public void queryGoodsByName(JSONObject reqJson,String searchValue,String shopId, List<ProductDto> allProductDtos) {
        ProductDto productDto = new ProductDto();
        productDto.setPage(1);
        productDto.setRow(20);
        productDto.setShopId(shopId);
        productDto.setProdNameLike(searchValue);
        List<ProductDto> productDtos = productInnerServiceSMOImpl.queryProducts(productDto);
        if(ListUtil.isNull(productDtos)){
            return;
        }
        allProductDtos.addAll(productDtos);
    }

    @Override
    public void queryGoodsById(JSONObject reqJson,String searchValue,String shopId, List<ProductDto> allProductDtos) {
        ProductDto productDto = new ProductDto();
        productDto.setPage(1);
        productDto.setRow(20);
        productDto.setShopId(shopId);
        productDto.setProductId(searchValue);
        List<ProductDto> productDtos = productInnerServiceSMOImpl.queryProducts(productDto);
        if(ListUtil.isNull(productDtos)){
            return;
        }
        allProductDtos.addAll(productDtos);
    }
}
